import gugga.common.UIComponentEx;
import gugga.navigation.NavigationButton;
import gugga.utils.DrawUtil;

/**
 * @author bony
 * The "LabelNavigationButton" is navigation button with text get from the xml. Has the information for the width
 * of the button, which is necessary to LayoutGenerator.   
 */
class externalContent.LabelNavigationButton extends NavigationButton 
{ 
		
	private var mLabel : TextField;
	private var mLabelContainer : MovieClip;
	
	public function LabelNavigationButton(aClient:UIComponentEx) 
	{
		super();
		
		// In the "LabelNavigationButton" has a movie clip "mcContainerLabel".The container "mcContainerLabel" is used
		// to prevent the killing of the text field in the key frames. 	
		mLabelContainer = this.getComponent("mcContainerLabel");
		mLabel = this.getComponentByPath(["mcContainerLabel", "txtLabel"]);
		
		mLabel.autoSize = "left";
	}

	public function get Label() : String 
	{ 
		return mLabel.htmlText; 
	}	

	public function get LabelTextField() : TextField 
	{ 
		return mLabel; 
	}
	
	public function set Label(aValue:String) : Void 
	{ 
		mLabel.htmlText = aValue; 
		createHitArea();
	}
	
	public function get width()
	{
		return mLabelContainer._width;  
	}

	private function createHitArea() : Void
	{	
		if(this["hit"])
		{
			MovieClip(this["hit"]).removeMovieClip();
		}
		
		DrawUtil.createCoverForMovieClip("hit", this, mLabelContainer);
	}

}